var maxDigits, ZERO_ARRAY, bigZero, bigOne, dpl10, lr10, hexatrigesimalToChar, hexToChar, highBitMasks, lowBitMasks, biRadixBase = 2, biRadixBits = 16, bitsPerDigit = biRadixBits, biRadix = 65536, biHalfRadix = biRadix >>> 1, biRadixSquared = biRadix * biRadix, maxDigitVal = biRadix - 1, maxInteger = 9999999999999998;
setMaxDigits(20),
dpl10 = 15,
hexatrigesimalToChar = new Array("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"),
hexToChar = new Array("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"),
highBitMasks = new Array(0,32768,49152,57344,61440,63488,64512,65024,65280,65408,65472,65504,65520,65528,65532,65534,65535),
lowBitMasks = new Array(0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535);

function reverseStr(a) {
    var c, b = "";
    for (c = a.length - 1; c > -1; --c)
        b += a.charAt(c);
    return b
}

function digitToHex(a) {
    var b = 15
      , c = "";
    for (i = 0; 4 > i; ++i)
        c += hexToChar[a & b],
        a >>>= 4;
    return reverseStr(c)
}

function biToString(a, b) {
    var d, e, c = new BigInt;
    for (c.digits[0] = b,
    d = biDivideModulo(a, c),
    e = hexatrigesimalToChar[d[1].digits[0]]; 1 == biCompare(d[0], bigZero); )
        d = biDivideModulo(d[0], c),
        digit = d[1].digits[0],
        e += hexatrigesimalToChar[d[1].digits[0]];
    return (a.isNeg ? "-" : "") + reverseStr(e)
}

function biToHex(a) {
    var d, b = "";
    for (biHighIndex(a),
    d = biHighIndex(a); d > -1; --d)
        b += digitToHex(a.digits[d]);
    return b
}

function biNumBits(a) {
    var e, b = biHighIndex(a), c = a.digits[b], d = (b + 1) * bitsPerDigit;
    for (e = d; e > d - bitsPerDigit && 0 == (32768 & c); --e)
        c <<= 1;
    return e
}

function biShiftLeft(a, b) {
    var e, f, g, h, c = Math.floor(b / bitsPerDigit), d = new BigInt;
    for (arrayCopy(a.digits, 0, d.digits, c, d.digits.length - c),
    e = b % bitsPerDigit,
    f = bitsPerDigit - e,
    g = d.digits.length - 1,
    h = g - 1; g > 0; --g,
    --h)
        d.digits[g] = d.digits[g] << e & maxDigitVal | (d.digits[h] & highBitMasks[e]) >>> f;
    return d.digits[0] = d.digits[g] << e & maxDigitVal,
    d.isNeg = a.isNeg,
    d
}

function biMultiplyDigit(a, b) {
    var c, d, e, f;
    for (result = new BigInt,
    c = biHighIndex(a),
    d = 0,
    f = 0; c >= f; ++f)
        e = result.digits[f] + a.digits[f] * b + d,
        result.digits[f] = e & maxDigitVal,
        d = e >>> biRadixBits;
    return result.digits[1 + c] = d,
    result
}

function biMultiplyByRadixPower(a, b) {
    var c = new BigInt;
    return arrayCopy(a.digits, 0, c.digits, b, c.digits.length - b),
    c
}

function BigInt(a) {
	this.digits = "boolean" == typeof a && 1 == a ? null : ZERO_ARRAY.slice(0),
		this.isNeg = !1
}

function arrayCopy(a, b, c, d, e) {
    var g, h, f = Math.min(b + e, a.length);
    for (g = b,
    h = d; f > g; ++g,
    ++h)
        c[h] = a[g]
}

function biAdd(a, b) {
    var c, d, e, f;
    if (a.isNeg != b.isNeg)
        b.isNeg = !b.isNeg,
        c = biSubtract(a, b),
        b.isNeg = !b.isNeg;
    else {
        for (c = new BigInt,
        d = 0,
        f = 0; f < a.digits.length; ++f)
            e = a.digits[f] + b.digits[f] + d,
            c.digits[f] = 65535 & e,
            d = Number(e >= biRadix);
        c.isNeg = a.isNeg
    }
    return c
}

function biShiftRight(a, b) {
	var e, f, g, h, c = Math.floor(b / bitsPerDigit),
		d = new BigInt;
	for (arrayCopy(a.digits, c, d.digits, 0, a.digits.length - c),
		e = b % bitsPerDigit,
		f = bitsPerDigit - e,
		g = 0,
		h = g + 1; g < d.digits.length - 1; ++g,
		++h)
		d.digits[g] = d.digits[g] >>> e | (d.digits[h] & lowBitMasks[e]) << f;
	return d.digits[d.digits.length - 1] >>>= e,
		d.isNeg = a.isNeg,
		d
}

function biCompare(a, b) {
	if (a.isNeg != b.isNeg)
		return 1 - 2 * Number(a.isNeg);
	for (var c = a.digits.length - 1; c >= 0; --c)
		if (a.digits[c] != b.digits[c])
			return a.isNeg ? 1 - 2 * Number(a.digits[c] > b.digits[c]) : 1 - 2 * Number(a.digits[c] < b.digits[c]);
	return 0
}


function biSubtract(a, b) {
	var c, d, e, f;
	if (a.isNeg != b.isNeg)
		b.isNeg = !b.isNeg,
		c = biAdd(a, b),
		b.isNeg = !b.isNeg;
	else {
		for (c = new BigInt,
			e = 0,
			f = 0; f < a.digits.length; ++f)
			d = a.digits[f] - b.digits[f] + e,
			c.digits[f] = 65535 & d,
			c.digits[f] < 0 && (c.digits[f] += biRadix),
			e = 0 - Number(0 > d);
		if (-1 == e) {
			for (e = 0,
				f = 0; f < a.digits.length; ++f)
				d = 0 - c.digits[f] + e,
				c.digits[f] = 65535 & d,
				c.digits[f] < 0 && (c.digits[f] += biRadix),
				e = 0 - Number(0 > d);
			c.isNeg = !a.isNeg
		} else
			c.isNeg = a.isNeg
	}
	return c
}

function biModuloByRadixPower(a, b) {
	var c = new BigInt;
	return arrayCopy(a.digits, 0, c.digits, 0, b),
		c
}

function biMultiply(a, b) {
	var d, h, i, k, c = new BigInt,
		e = biHighIndex(a),
		f = biHighIndex(b);
	for (k = 0; f >= k; ++k) {
		for (d = 0,
			i = k,
			j = 0; e >= j; ++j,
			++i)
			h = c.digits[i] + a.digits[j] * b.digits[k] + d,
			c.digits[i] = h & maxDigitVal,
			d = h >>> biRadixBits;
		c.digits[k + e + 1] = d
	}
	return c.isNeg = a.isNeg != b.isNeg,
		c
}

function biDivideByRadixPower(a, b) {
	var c = new BigInt;
	return arrayCopy(a.digits, b, c.digits, 0, c.digits.length - b),
		c
}

function biDivideModulo(a, b) {
	var f, g, h, i, j, k, l, m, n, o, p, q, r, s, c = biNumBits(a),
		d = biNumBits(b),
		e = b.isNeg;
	if (d > c)
		return a.isNeg ? (f = biCopy(bigOne),
				f.isNeg = !b.isNeg,
				a.isNeg = !1,
				b.isNeg = !1,
				g = biSubtract(b, a),
				a.isNeg = !0,
				b.isNeg = e) : (f = new BigInt,
				g = biCopy(a)),
			new Array(f, g);
	for (f = new BigInt,
		g = a,
		h = Math.ceil(d / bitsPerDigit) - 1,
		i = 0; b.digits[h] < biHalfRadix;)
		b = biShiftLeft(b, 1),
		++i,
		++d,
		h = Math.ceil(d / bitsPerDigit) - 1;
	for (g = biShiftLeft(g, i),
		c += i,
		j = Math.ceil(c / bitsPerDigit) - 1,
		k = biMultiplyByRadixPower(b, j - h); - 1 != biCompare(g, k);)
		++f.digits[j - h],
		g = biSubtract(g, k);
	for (l = j; l > h; --l) {
		for (m = l >= g.digits.length ? 0 : g.digits[l],
			n = l - 1 >= g.digits.length ? 0 : g.digits[l - 1],
			o = l - 2 >= g.digits.length ? 0 : g.digits[l - 2],
			p = h >= b.digits.length ? 0 : b.digits[h],
			q = h - 1 >= b.digits.length ? 0 : b.digits[h - 1],
			f.digits[l - h - 1] = m == p ? maxDigitVal : Math.floor((m * biRadix + n) / p),
			r = f.digits[l - h - 1] * (p * biRadix + q),
			s = m * biRadixSquared + (n * biRadix + o); r > s;)
			--f.digits[l - h - 1],
			r = f.digits[l - h - 1] * (p * biRadix | q),
			s = m * biRadix * biRadix + (n * biRadix + o);
		k = biMultiplyByRadixPower(b, l - h - 1),
			g = biSubtract(g, biMultiplyDigit(k, f.digits[l - h - 1])),
			g.isNeg && (g = biAdd(g, k),
				--f.digits[l - h - 1])
	}
	return g = biShiftRight(g, i),
		f.isNeg = a.isNeg != e,
		a.isNeg && (f = e ? biAdd(f, bigOne) : biSubtract(f, bigOne),
			b = biShiftRight(b, i),
			g = biSubtract(b, g)),
		0 == g.digits[0] && 0 == biHighIndex(g) && (g.isNeg = !1),
		new Array(f, g)
}


function charToHex(a) {
	var h, b = 48,
		c = b + 9,
		d = 97,
		e = d + 25,
		f = 65,
		g = 90;
	return h = a >= b && c >= a ? a - b : a >= f && g >= a ? 10 + a - f : a >= d && e >= a ? 10 + a - d : 0
}


function BarrettMu_powMod(a, b) {
	var d, e, c = new BigInt;
	for (c.digits[0] = 1,
		d = a,
		e = b;;) {
		if (0 != (1 & e.digits[0]) && (c = this.multiplyMod(c, d)),
			e = biShiftRight(e, 1),
			0 == e.digits[0] && 0 == biHighIndex(e))
			break;
		d = this.multiplyMod(d, d)
	}
	return c
}

function BarrettMu_multiplyMod(a, b) {
	var c = biMultiply(a, b);
	return this.modulo(c)
}

function BarrettMu_modulo(a) {
	var i, b = biDivideByRadixPower(a, this.k - 1),
		c = biMultiply(b, this.mu),
		d = biDivideByRadixPower(c, this.k + 1),
		e = biModuloByRadixPower(a, this.k + 1),
		f = biMultiply(d, this.modulus),
		g = biModuloByRadixPower(f, this.k + 1),
		h = biSubtract(e, g);
	for (h.isNeg && (h = biAdd(h, this.bkplus1)),
		i = biCompare(h, this.modulus) >= 0; i;)
		h = biSubtract(h, this.modulus),
		i = biCompare(h, this.modulus) >= 0;
	return h
}

function biDivide(a, b) {
	return biDivideModulo(a, b)[0]
}

function biCopy(a) {
	var b = new BigInt(!0);
	return b.digits = a.digits.slice(0),
		b.isNeg = a.isNeg,
		b
}

function hexToDigit(a) {
	var d, b = 0,
		c = Math.min(a.length, 4);
	for (d = 0; c > d; ++d)
		b <<= 4,
		b |= charToHex(a.charCodeAt(d));
	return b
}

function BarrettMu(a) {
	this.modulus = biCopy(a),
		this.k = biHighIndex(this.modulus) + 1;
	var b = new BigInt;
	b.digits[2 * this.k] = 1,
		this.mu = biDivide(b, this.modulus),
		this.bkplus1 = new BigInt,
		this.bkplus1.digits[this.k + 1] = 1,
		this.modulo = BarrettMu_modulo,
		this.multiplyMod = BarrettMu_multiplyMod,
		this.powMod = BarrettMu_powMod
}

function biHighIndex(a) {
	for (var b = a.digits.length - 1; b > 0 && 0 == a.digits[b];)
		--b;
	return b
}

function BigInt(a) {
	this.digits = "boolean" == typeof a && 1 == a ? null : ZERO_ARRAY.slice(0),
		this.isNeg = !1
}

function biFromHex(a) {
	var d, e, b = new BigInt,
		c = a.length;
	for (d = c,
		e = 0; d > 0; d -= 4,
		++e)
		b.digits[e] = hexToDigit(a.substr(Math.max(d - 4, 0), Math.min(d, 4)));
	return b
}



function setMaxDigits(a) {
	maxDigits = a,
		ZERO_ARRAY = new Array(maxDigits);
	for (var b = 0; b < ZERO_ARRAY.length; b++)
		ZERO_ARRAY[b] = 0;
	bigZero = new BigInt,
		bigOne = new BigInt,
		bigOne.digits[0] = 1
}

function RSAKeyPair(a, b, c) {
	this.e = biFromHex(a),
		this.d = biFromHex(b),
		this.m = biFromHex(c),
		this.chunkSize = 2 * biHighIndex(this.m),
		this.radix = 16,
		this.barrett = new BarrettMu(this.m)
}

function encryptedString(a, b) {
    for (var f, g, h, i, j, k, l, c = new Array, d = b.length, e = 0; d > e; )
        c[e] = b.charCodeAt(e),
        e++;
    for (; 0 != c.length % a.chunkSize; )
        c[e++] = 0;
    for (f = c.length,
    g = "",
    e = 0; f > e; e += a.chunkSize) {
        for (j = new BigInt,
        h = 0,
        i = e; i < e + a.chunkSize; ++h)
            j.digits[h] = c[i++],
            j.digits[h] += c[i++] << 8;
        k = a.barrett.powMod(j, a.e),
        l = 16 == a.radix ? biToHex(k) : biToString(k, a.radix),
        g += l + " "
    }
    return g.substring(0, g.length - 1)
}

function rsa_encrypt(a, b, c) {
		var d, e;
		return setMaxDigits(131),
			d = new RSAKeyPair(b, "", c),
			e = encryptedString(d, a)
}